/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package GUI;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
import sphere.OI; 
/**
 *
 * @author Carter
 */
public class Swing {
    JFrame j;
    JPanel p;
    JButton desire;
    DesireOpt deso;
    JButton checker;
    JLabel xReport;
    JLabel yReport;
    JLabel zReport;
    JLabel energy;
    JLabel level;
    final OI oi;
    public Swing(){
        
        j = new JFrame("Sphere");
        p = new JPanel();
        oi = new OI();
        xReport = new JLabel();
        yReport = new JLabel();
        zReport = new JLabel();
        deso = new DesireOpt();
        desire = new JButton("New Point");
        checker = new JButton("Get New Data");
        j.setBounds(50,50,800,250);
        p.setLayout(null);
        desire.addActionListener(new ActionListener(){
          public void actionPerformed(ActionEvent e ){
                    deso.j.setVisible(true);
             }
            });
        checker.addActionListener(new ActionListener(){
          public void actionPerformed(ActionEvent e ){
                oi.carter.newDesiredPoints(deso.xVal, deso.yVal, deso.zVal);
                double xDiff = oi.AC.getDifferenceX(oi.carter.x, oi.carter.desiredX);
                double yDiff = oi.AC.getDifferenceY(oi.carter.y, oi.carter.desiredY);
                double zDiff = oi.AC.getDifferenceZ(oi.carter.z, oi.carter.desiredZ);
                double dist = oi.AC.getDistanceToPoint(xDiff, yDiff, zDiff);
                xReport.setText("X Distance: " +xDiff);
                yReport.setText("Y Distance: " +yDiff);
                zReport.setText("Z Distance: " +zDiff);
                oi.carter.x = oi.carter.desiredX;
                oi.carter.y = oi.carter.desiredY;
                oi.carter.z = oi.carter.desiredZ;
                //oi.carter.getTotalEnergy();
                 
                
             }
            });
}
    
    
    public void go(){
        xReport.setBounds(50,50,150,50);
        yReport.setBounds(50,100,150,50);
        zReport.setBounds(50,150,150,50);
        desire.setBounds(500,50,100,50);
        checker.setBounds(500,150,150,50);
        j.add(p);
        p.add(xReport);
        p.add(yReport);
        p.add(zReport);
        p.add(desire);
        p.add(checker);
        j.setVisible(true);
    }

}

